<?php

class MovieView extends View {

	protected $movie;
	protected $movieList;
	protected $actorsPlayed;

	function __construct() {
	
	}
	
	function getActorsPlayed() {
		return $this->actorsPlayed;
	}
	
	function setActorsPlayed($m) {
		$this->actorsPlayed = $m;
	}
	
	function getMovie() {
		return $this->movie;
	}
	
	function setMovie($m) {
		$this->movie = $m;
	}
	
	function getMovieList() {
		return $this->movieList;
	}
	
	function setMovieList($m) {
		$this->movieList = $m;
	}
	
	function display() {
		echo '<div style="width:90%">';
		echo '<table border=0>';
		echo '<form method="POST" action="?page=buy&view=movie">';
		echo '<tr><td>Title: </td><td>'.$this->movie->getTitle().'</td></tr>';
		echo '<tr><td>Year:</td><td>'.$this->movie->getYear().'</td></tr>';
		echo '<tr><td>Director Name:</td><td>'.$this->movie->getDirectorFirstName().' '.$this->movie->getDirectorLastName().'</td></tr>';
		echo '<tr><td>Rating:</td><td>'.$this->movie->getRating().'</td></tr>';
		echo '<tr><td>Copies:</td><td><input type="text" name="copies" value="'.$this->movie->getNoCopies().'" /></td></tr>';
		echo '<tr><td>Price:</td><td>'.$this->movie->getPrice().'</td></tr>';
		
		echo '<input type="hidden" name="action" value="save" />';
		echo '<input type="hidden" name="movieId" value="'.$this->movie->getId().'" />';
		echo '<input type="hidden" name="title" value="'.$this->movie->getTitle().'" />';
		echo '<input type="hidden" name="price" value="'.$this->movie->getPrice().'"/ >';
		
		echo '<tr><td></td><td><input type="submit" value="Order it" class="btn btn-default" /></td></tr>';
		
		echo '</table>';
		
		echo '</form>';
		
		echo '<br />';
		echo '<hr />';
		echo '<br />';
		if ($this->actorsPlayed) {
			echo '<h3>Actors Played</h3>';
			echo '<table class="table table-striped">';
			echo '<thead><th>id</th><th>Name</th><th>Surname</th><th>isMajor</th></thead>';
			foreach ($this->actorsPlayed as $actor) {
				echo '<tr><td>'.$actor->getId().'</td>
						<td>'.$actor->getFirstName().'</td>
						<td>'.$actor->getLastName().'</td>
						<td>'.$actor->getIsMajor().'</td>
						</tr>';
			}
			echo '</table>';
			
			echo '<br />';
			echo '<hr />';
			echo '<br />';
		}
		
		if ($this->movieList) {
			echo '<h3>Suggestions</h3>';
			echo '<table class="table table-striped">';
			echo '<thead><th>id</th><th>Title</th><th>Year of release</th><th>Director</th><th>Rating</th><th>Copies Available</th><th>Price</th></thead>';
			foreach ($this->movieList as $movie) {
				echo '<tr><td>'.$movie->getId().'</td>
						<td><a href="?page=buy&view=movie&movieId='
															.$movie->getId().'&movieName='.$movie->getTitle().'&noCopies='
															.$movie->getNoCopies().'">'.$movie->getTitle().'</a></td>
						<td>'.$movie->getYear().'</td>
						<td>'.$movie->getDirectorFirstName().' '.$movie->getDirectorLastName().'</td>
						<td>'.$movie->getRating().'</td>
						<td>'.$movie->getNoCopies().'</td>
						<td>'.$movie->getPrice().'</td>
						</tr>';
			}
			echo '</table>';
		}
		
		echo '</div>';
		
		
	}
	

}

?>